In general, floating-point notation represents a number in the form ±0.ddd . . . d×be, where b is a base, each d is a digit from 0 to b−1, and e is an integer exponent. The digits (d) are collectively referred to as a mantissa. The number of digits in the mantissa is typically fixed for a particular floating-point representation. For example, in the most common current form of floating-point representation (i.e., Institute of Electrical and Electronics Engineers (IEEE) 754 binary standard), the base (b) is 2, the exponent (e) ranges from −1023 to +1024 (represented using 11 bits), and the mantissa is represented using 53 bits (including a bit for the sign of the number).
Numbers are represented in floating-point notation in a wide variety of computer applications. Specifically, programmers represent numbers in floating-point notation when the accuracy of the number is important for the particular application. However, a programmer's reliance on the accuracy of a given number in floating-point notation may be unfounded. In many cases, simple arithmetic operations such as addition, subtraction, multiplication, etc. introduce accuracy loss that is often hard to detect, and yet is important to understand. For example, the addition of ½ to one million one thousand times, is 0.1000500×107. In a system with seven decimals of precision, due to rounding of the intermediate result after each addition of ½, the result is typically represented as 0.1000000×107. Depending on what this particular number, represented in floating-point notation, is to be used for, a difference of five hundred may be significant. Accordingly, it is desirable to have an understanding of the accuracy of the number represented in the mantissa, when the number is used in a computer application.
One conventional approach to determine the accuracy of a number represented in floating-point notation uses interval arithmetic (IA). Using this method, numbers represented using floating-point notation are replaced with intervals that bound the result (final or intermediate) when the number cannot be expressed exactly by the computer application (i.e., the number of mantissa bits required to represented the number exceeds the number of mantissa bits available to represent the number, e.g., a number requires nine bits to be exactly represented but the mantissa in the given floating-point representation is only allocated seven bits).
Accordingly, IA provides a means to indicate to the programmer whether the given number, represented in floating-point notation, is exact or inexact. However, IA typically provides no information about the cause of the inaccuracy or inability of the computer program to accurately represent the result in floating-point notation. In addition, IA typically requires low level-access to the rounding modes of the processor upon which the computer application is running.
A second conventional approach to determine the accuracy of a number represented in floating-point notation modifies the level of precision in the processor executing the computer application and determines whether the change in precision (e.g., from 14 decimals in the mantissa to 11 decimals in the mantissa) has an effect on the accuracy of the results. This approach provides a means to identify whether a given result is exact or inexact, as well as to determine, what level of precision is required to represent the result. However, this approach does not typically provide any information as to the cause of the inaccuracy of the results.